Floor sensors
OLEM has 6 sensors constantly detecting the floor. They return a signal proportional to the color of the area directly underneath the sensor. With a white surface resulting in the strongest signal and a black one or no surface at all giving the weakest signal.
Their index can be seen in the picture below:

For convenience, the signal is already processed and the API can be used to :
- check if the floor is detected (aka we are on the board and not the edge), see
ir_floor_is_floor_present() - count the sensors that do not see the floor, see
ir_floor_get_void_count() - get the signal of each sensor, see
ir_floor_get_sensor_value() - check if a card has been detected [Python API coming soon]
- check if a tile edge is detected [Python API coming soon]
The sides of OLEM are given with the FRONT, RIGHT, BACK and LEFT constants, listed with the side sensors.
Example
Lift the sides of OLEM one at a time: the sides without floor are printed.
import olem
print("Lift the sides of OLEM one at a time")
start = olem.get_time_ms()
while olem.get_time_ms() - start < 20000:
sides = ""
if not olem.ir_floor_is_floor_present(olem.FRONT):
sides += "F"
if not olem.ir_floor_is_floor_present(olem.RIGHT):
sides += "R"
if not olem.ir_floor_is_floor_present(olem.BACK):
sides += "B"
if not olem.ir_floor_is_floor_present(olem.LEFT):
sides += "L"
if sides:
print("No floor: " + sides + ", " + str(olem.ir_floor_get_void_count()) + " sensors see the void")
olem.delay_ms(200)
Functions
ir_floor_get_sensor_value(sensor)
Get the signal of a floor sensor. The signal is the strongest on a white surface and the weakest on a black surface or when there is no floor.
OLEM has 6 floor sensors, numbered clockwise: 0 front left, 1 front right, 2 right, 3 back right, 4 back left, 5 left.
| Parameter | Description |
|---|---|
sensor | index of the sensor, from 0 to 5 |
Returns: signal in ADC units (LSB), or 0 if sensor is not valid
ir_floor_is_floor_present(side)
Check if there is floor under a side of OLEM, to detect the edge of the board or table.
| Parameter | Description |
|---|---|
side | FRONT, RIGHT, BACK or LEFT |
Returns: True if the floor is detected, False otherwise or if side is not valid
ir_floor_get_void_count()
Returns: number of floor sensors that do not see the floor